package ia;

import book.Book;
import book.Booklist;

import java.util.Scanner;

public class Returnbook implements IA{
    public void work(Booklist booklist){
        System.out.println("归还图书.........");

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你要归还的书名");
        String bookname = sc.nextLine();

        int cutsize = booklist.getUsesize();
        for (int i = 0; i < cutsize; i++) {
            Book book = booklist.getBooks(i);
            if (book.getTitle().equals(bookname)) {
                if(!(book.getAvailable())) {
                    System.out.println("该书已经被归还");
                    return;
                }
                book.setAvailable(false);
                System.out.println("已成功归还");
                return;
            }
        }
        System.out.println("没找到你想要归还的书");
    }
}
